module BetsHelper
  def bet_status(bet)
    if bet.played?
      str = case bet.win
        when nil
          image_tag("draw.png")
        when true
          if bet.winstreak_value == 0.5
            image_tag("half_win.png")
          else
            image_tag("win.png")
          end
        when false
          if bet.winstreak_value == 0.5
            image_tag("half_lose.png")
          else
            image_tag("lose.png")
          end
      end
      str << "<br/>" + format_time(bet.match.begin_at,:date)
    else
      format_time bet.match.begin_at,:datetime
    end
  end

  def bet_html_class(bet,team_id)
    if bet.team_id == team_id
      "class='bet-selected'"
    else
      ""
    end
  end

  def bet_html_style(bet,team_id)
    base_style = "border-color:#D8DFEA;border-style:dotted dotted solid;border-width:1px;padding:4px;text-align:center;"
    bet_html_class(bet,team_id).blank? ? "style='#{base_style}'" : "style='#{base_style}background-color:#E7FBC8;'"
  end
end
